package com.lzwk.beans.ocpx;

import com.lzwk.app.dwd.ocpx.DwdToDoris;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.sql.Timestamp;

/**
 * @title: DWDPAYORDER
 * @Author Yeaser
 * @Date: 2022/2/15 19:22
 * @Version 1.0
 * Description: TODO
 */
@AllArgsConstructor
@NoArgsConstructor
@Data
public class DwdPayOrder {

    private int id;
    private int payer_id;
    private int product_id;
    private int wk_account_id;
    private int parent_activity_id;
    private int src_prod_id;
    private int org_id;
    private String ks_id;
    private String product_name;
    private int skin_id;
    private String skin_name;
    private int source_id;
    private String source_name;
    private int wxapp_id;
    private String wxapp_nickname;
    private String nickname;
    private String headmgurl;
    private String phone_num;
    private String creative_id;
    private String ad_plan_id;
    private String ad_group_id;
    private String gdt_group_id;
    private String bd_creative_id;
    private int fee;
    private int paid;
    private String create_time;
    private String pay_time;
    private int subscribed;
    private int tag_id;
    private String tag_name;
    private String source_platform;
    private int refund_status;
    private String meta;
    private String hash_id;
    private String trace_id;
    private String appid;


    public DwdPayOrder(DwdOrder dwdOrder, OdsAccountWxuser odsAccountWxuser) {
        mergeOrder(dwdOrder);
        //匹配上就用wxuser的subsrcibed字段
        mergeMatchedWxuser(odsAccountWxuser);
    }

    public DwdPayOrder(DwdOrder dwdOrder, boolean flag) {
        mergeOrder(dwdOrder);
        //匹配不上就用默认值0代替
        this.subscribed = 0;
    }

    private void mergeMatchedWxuser(OdsAccountWxuser odsAccountWxuser) {
        if(odsAccountWxuser != null){
            this.subscribed = odsAccountWxuser.getSubscribed();
        }
    }

    private void mergeOrder(DwdOrder dwdOrder) {
        if (dwdOrder != null) {
            this.id = dwdOrder.getId();
            this.payer_id = dwdOrder.getId();
            this.product_id = dwdOrder.getId();
            this.wk_account_id = dwdOrder.getWk_account_id();
            this.parent_activity_id = dwdOrder.getParent_activity_id();
            this.src_prod_id = dwdOrder.getSrc_prod_id();
            this.org_id = dwdOrder.getOrg_id();
            this.ks_id = dwdOrder.getKs_id();
            this.product_name = dwdOrder.getProduct_name();
            this.skin_id = dwdOrder.getSkin_id();
            this.skin_name = dwdOrder.getSkin_name();
            this.source_id = dwdOrder.getSource_id();
            this.source_name = dwdOrder.getSource_name();
            this.wxapp_id = dwdOrder.getWxapp_id();
            this.wxapp_nickname = dwdOrder.getWxapp_nickname();
            this.nickname = dwdOrder.getNickname();
            this.headmgurl = dwdOrder.getHeadmgurl();
            this.phone_num = dwdOrder.getPhone_num();
            this.creative_id = dwdOrder.getCreative_id();
            this.ad_plan_id = dwdOrder.getAd_plan_id();
            this.ad_group_id = dwdOrder.getAd_group_id();
            this.gdt_group_id = dwdOrder.getGdt_group_id();
            this.bd_creative_id = dwdOrder.getBd_creative_id();
            this.fee = dwdOrder.getFee();
            this.paid = dwdOrder.getPaid();
            this.create_time = dwdOrder.getCreate_time().toString();
            this.pay_time = dwdOrder.getPay_time().toString();
            this.tag_id = dwdOrder.getTag_id();
            this.tag_name = dwdOrder.getTag_name();
            this.source_platform = dwdOrder.getSource_platform();
            this.refund_status = dwdOrder.getRefund_status();
        }
    }
}
